home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_02 / cepek / fmutl.h < prev   
Encoding:
C/C++ Source or Header  |  1994-11-28  |  2.5 KB  |  74 lines

  1. /*############################  Listing 1:  ############################*/
  2.  
  3. /* fmutl.h - flash memory utility module header */
  4.  
  5.  
  6. #ifndef FMUTL_H_
  7. #define    FMUTL_H_
  8.  
  9.  
  10.  
  11.     /* macro returning number of elements in an array: */
  12. #define    ARRAY_LEN(a)    (sizeof(a) / sizeof((a)[0]))
  13.  
  14.  
  15. /*****************************************************************************
  16. The fm_status() routine can return the following information about flash
  17. memory devices.  NOTE:  fields ending with '_' are intended for internal
  18. use by fmutl.c only:
  19. *****************************************************************************/
  20.  
  21. typedef struct    {    /** Flash Memory information structure: **/
  22.         /* private: */
  23.     unsigned short MfrID_;        /* (manufacturer ID code) */
  24.     unsigned short DevID_;        /* (device ID code) */
  25.     short MaxErase_;        /* (max erase time in seconds) */
  26.     short MaxWrite_;        /* (max byte-write time in ms) */
  27.     int NumSect_;            /* (number of sectors per chip) */
  28.         /* public: */
  29.     size_t SectorSize;        /* bytes per sector (both chips) */
  30.     size_t TotalSize;        /* total number of bytes (both chips) */
  31.     int NumProt;            /* >= 0: # of protected sectors;
  32.                       -1: prot. sectors are non-contiguous
  33.                       -2: prot. mismatched b/w devices */
  34.     int FirstProt;            /* first protected sector, ordinal 0 */
  35.     char *pDevName;            /* ptr to manufacturer & device name */
  36. } FMINFO;
  37.  
  38.  
  39. /*****************************************************************************
  40. If the return value of a routine in fmutl.c indicates failure, the fm_err
  41. global structure will contain the following additional information about
  42. the error.
  43. *****************************************************************************/
  44.  
  45. typedef    struct    {    /** Flash routine error information structure: **/
  46.     unsigned short *addr;    /* flash memory address of problem */
  47.     unsigned short exp;    /* value expected */
  48.     unsigned short act;    /* actual value read */
  49.     unsigned char code;    /* error code byte (see fmutl.c) */
  50.     char *pMsg;        /* ptr to error message string */
  51. } FMERR;
  52.  
  53. extern    FMERR    fm_err;        /* defined in fmutl.c */
  54.  
  55.  
  56. /*****************************************************************************
  57. Prototypes for the global routines in fmutl.c:
  58. *****************************************************************************/
  59.  
  60. #ifdef __STDC__
  61.  
  62. extern fm_status(unsigned short *pBase, FMINFO *pFMInfo);
  63.  
  64. extern fm_write(unsigned short *pBase, unsigned short *pDst,
  65.         unsigned short *pSrc, size_t length, unsigned short *pScrBuf);
  66.  
  67. extern void fm_error(unsigned short *addr, unsigned short exp,
  68.              unsigned short act, int errcode);
  69.  
  70. #endif
  71.  
  72. #endif  /* FMUTL_H_ */
  73.  
  74.